import matplotlib.pyplot as plt
import numpy as np
import os

def ACT():
    x_data = ['MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF']
    ind = np.arange(len(x_data))
    y_data1 = [52.00778781082408, 50.7955138934908, 51.18053914106581, 48.38811614843125, 50.562276673357374, 50.562276673357374, 50.88531310758844, 31.934663383325997, 50.99749673330266, 47.35361867241695, 51.80854568500669, 51.801019020788644]
    y_data2 = [52.49840182648402, 51.48413053196245, 51.64652631578947, 48.73736263736264, 51.201945443011205, 51.201945443011205, 51.56049486265464, 32.2982032716546, 51.695743342419796, 47.7596241979835, 53.59650548557497, 53.585940674522554]
    w = 0.2
    ax = plt.subplot(111)
    a = ax.bar(ind,y_data1,width=0.2,align='center',color='red')
    b = ax.bar(ind+w,y_data2,width=0.2,align='center', color='lightseagreen')
    ax.set_xticks(ind+w)
    ax.set_xticklabels( ('MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF') )
    plt.legend((a,b),('ave ACT','worst ACT'))
    plt.autoscale(tight=True)
    plt.title('The average/worst ACT')
    plt.tight_layout()
    graph_path = os.path.dirname(os.path.abspath(__file__)) + '/graph/'
    if not os.path.isdir(graph_path):
        os.makedirs(graph_path)
    file_name = graph_path + __file__.split('/')[-1].split('.')[0]
    plt.savefig(f"{file_name}.pdf", bbox_inches='tight')
    plt.close()


if __name__ == '__main__':
    ACT()